﻿/*
 * Copyright (C) 2021. Huawei Device Co., Ltd. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the MIT License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * MIT License for more details.
 */

#ifndef DUILIB_UICULTURE_H
#define DUILIB_UICULTURE_H

#include <vector>
#include "UICultureInterface.h"
#include "UICultureImplement.h"

namespace DuiLib {

class UILIB_API UICulture : public DuiLib::UICultureInterface {
public:
    ~UICulture();
    static UICulture* GetInstance();

    void setResPath(LPCTSTR path) override;
    void setLocale(LPCTSTR locale, bool loadAll = true) override;
    LayoutDirection getDirection() override;

    CDuiString ParseBind(LPCTSTR pstrValue) override;
    CDuiString GetString(LPCTSTR key) override;
    CDuiString GetLocalString(LPCTSTR key) override;
    std::wstring GetLocaleLanguage() override;
    void SetCustomFont(wstring fontstr) override;

    wstring GetCustomFont() override;
    std::wstring GetMultiVarStringForDotnet(const wstring& localString,
        const vector<int>& nums, const string& language);
    std::wstring GetMultiVarStr(const wstring &strIDS, const vector<int> &vecNum,int count=0) override;
    wstring GetTextFromHtmlText(CPaintManagerUI* pManager, LPCTSTR pstrText, int iFont);
    CDuiString GetMultiVarString(LPCTSTR originalString, ...) override;
    int32_t UnicodeFormat(const string &pstrFormat, wstring &unicodeChar, va_list vaList);
    std::wstring GetPercentageStr(const int percentage) override;
    std::wstring ToUpper(const wstring &src) override;
    std::wstring NumberLocalFormat(double value) override;

private:
    UICulture() = default;
    std::vector<UICultureImplement *> cultureImplements;
    std::mutex sequentialOper;
    std::wstring defaultLocal = L"";
    bool defaultLoadAll = true;
};

} // namespace DuiLib

#endif // !DUILIB_UICULTURE_H
